<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>分省份部署 | 开通省份</title>
<@fm.header />
<style>
.provinceClass label {
	font-size: 12px;
	float:left;
	margin:2px;
	width:80px;
	height:20px;
}
</style>
</head>
<body>
<div class="easyui-layout" style="text-align: center; height: 270px;" fit="true">
	<div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
	<form id="ff" method="post">
		<input type="hidden" id="openProvince" name="openProvince" />
	    <div id="main-2">
	    	<h3>省份:</h3>
	    	<span class="provinceClass">
	    		<#if provinceList?exists>
					<#list provinceList as bean>
						   <label>
								<input type="checkbox"  value="${bean.id}" 
									<#if bean.checked == true>
										checked> <font color="#FF0000">${bean.provinceName}</font>
									<#else> 
									>${bean.provinceName}
									</#if> 
								 </input>
					    	</label>
					</#list>
				</#if>
	    	</span>
	    </div>
	</form>
	</div>
	<div region="south" border="false" style="text-align: center; padding: 5px 5px 5px 0;">
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm('/miguProvince/save');">提交</a>
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="allSelect()">全国</a>
	</div>
</div>
<script>
$(function(){
	$("input").bind("keyup afterpaste", function(){
		$(this).val($(this).val().replace(/\s/g,''));
	});
	
});
function allSelect(){
	if ($('#main-2').find('input:checked').length > 0) {
		$('#main-2').find('input').attr("checked",false);
	} else {
		$('#main-2').find('input').attr("checked",true);
	}
}
function submitForm(url) {
 	var f_str = '';
	$('#main-2').find('input:checked').map(function(idx, ele){
		f_str +=","+ $(ele).val();
	});
 	if(!f_str){
		showMsg(market.content.title, "请选择省份", alert);
	}else{
		$('#ff').form('submit',	{
		url : url,
		onSubmit : function() {
		 	$("input:hidden[name='openProvince']").val(f_str.substring(1));
			var flag = $(this).form('validate');
			if (flag) {
				showProcess(true, market.content.title, market.content.submitting);
			}
			return flag;
		},
		success : function(data) {
			showProcess(false);
			var data = eval('(' + data + ')');
			if (data.return_code == '1') {
				top.showMsg(market.content.title, data.return_msg, alert);
				if (parent !== undefined) {
					if ($.isFunction(parent.reloadParent)) {
						parent.reloadParent.call();
						parent.closeMyWindow();
					} else {
						parent.$("#tt").datagrid('reload');
						parent.closeMyWindow();
					}
				}
			} else {
				$.messager.alert(market.content.title, data.return_msg);
			}
		},
		onLoadError : function() {
			showProcess(false);
			$.messager.alert(market.content.title, market.content.networkError);
		}
	});
	}
}
</script>
</body>
</html>